package HospitalApplication;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PatientApplication implements Applications{
	
	private static Map <String, Patient> patientMap = new HashMap();
	
	@Override
	public boolean add(Person p) {
		if(p instanceof Patient) {
			patientMap.put(p.id, (Patient) p);
			return true;
		}
		else {
			System.out.println("The person is not a patient");
			return false;
		}
	}

	@Override
	public void printDetail(Person p) {
		if (p instanceof Patient) {
			Patient pat = (Patient) p;
			System.out.println("-------------------------");
			System.out.println("Name : " + pat.name);
			System.out.println("Age : " + pat.age);
			System.out.println("Sex : " + pat.sex);
			System.out.println("ID : " + pat.id);
			System.out.println("Sickness : " + pat.sickness);
			System.out.println("Date : " + pat.date);
			System.out.println("-------------------------");
		}
		else
			System.out.println("This person is not a patient!");
		
	}

	@Override
	public void printDetail(List<Person> PList) {
		for (Person person : PList) {
			printDetail(person);
		}
		
	}

	@Override
	public void printAll() {
		for (Map.Entry entry : patientMap.entrySet()) {
			printDetail((Patient) entry.getValue());
		}
		
	}
	
	public Patient getPatient(String id) {
		return patientMap.get(id);
	}
	
}
